*** Create Table A1, Illustrate Confounding ***

********************************************************************************


clear 

** read in .dta file **
use "${clean}/who_counts_descriptives.dta", clear

** regressions **

xi: reghdfe Schooling MOB Arabic Female age, a(serial) cluster(serial)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_Schooling_fe

xi: reghdfe French_Lit MOB Arabic Female age, a(serial) cluster(serial)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_French_Lit_fe

xi: reghdfe EDU_YRS MOB Arabic Female age, a(serial) cluster(serial)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace
estadd ysumm, replace
eststo m_EDU_YRS_fe

xi: reghdfe CM2 MOB Arabic Female age, a(serial) cluster(serial)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace
estadd ysumm, replace
eststo m_CM2_fe

xi: reghdfe MOB HoH_Registered Arabic Female age, a(geo2_ma) cluster(serial)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace
estadd ysumm, replace
eststo m_MOB_fe

** output the table

#delimit ; 
estout
	   m_Schooling_fe
	   m_French_Lit_fe
	   m_EDU_YRS_fe
	   m_CM2_fe
	   m_MOB_fe
       using "${output}/tables/TableA1.tex",
       style(tex) 
       cells(b(star fmt(3)) se(par fmt(3))) 
       varlabels(MOB "Month of Birth " sex "Women " ARABIC "First Language Arabic " Rural "Rural Household" HoH_Registered "HoH Registered ")
       drop(_cons)
	   stats(controls
	   adminFE
             r2 
             N
			 ymean, fmt(0 0 2 0 3 %9.0gc %9.0gc)
             labels("\hline Controls"
			 "\hline Admin FE"
                   "\hline \(R^2\)" 
                   " \hline N"
				   "Dep. Var. Mean ")) 
       mlabels(,none) 
       numbers
       collabels(none) 
       starl(* 0.1 ** 0.05 *** 0.01)
	          prehead( 
           \begin{table}[H]
           \caption{Association of Registration and Education, Morocco 1994}        
           \label{tab:FE}            
           \centering
           \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 
           \hline \hline                                
		   & \multicolumn{1}{c}{\textbf{Any Formal Schooling}}
		   & \multicolumn{1}{c}{\textbf{Literate in French and Arabic}} 
		   & \multicolumn{1}{c}{\textbf{Years of Education}} 
		   	   & \multicolumn{1}{c}{\textbf{Compulsory Schooling}} 
		   & \multicolumn{1}{c}{\textbf{Registered}}  \\                         
       )
       posthead(\hline) 
       prefoot() 
       postfoot(
           \noalign{\smallskip} \hline \hline 
           \end{tabular}
           \medskip
           \begin{minipage}{.9\textwidth}
           \tiny \justify Notes: \( @starlegend \). 
           \\ Columns 1-3 Household Fixed Effects, Clustered Robust Standard Errors at Household.\\
		   \\ Columns 4 Province Fixed Effects, Clustered Robust Standard Errors at Household.
           \end{minipage}        
       \end{table}
       )
       replace;
#delimit cr
